package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.entity.SystemExample;
import com.cskaoyan.bean.entity.Systems;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @program: project2_market
 * @time: 2021/10/18
 * @author: yangshuai
 **/

@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    SystemService systemService;


    /**
     * 获取商场配置
     * @return
     */
    @GetMapping("mall")
    public BaseRespVo queryMall(){

        SystemMallVo systems = systemService.selectMall();
        return BaseRespVo.ok(systems);
    }

    /**
     * 更新商场配置
     * @param systemMallVo
     * @return
     */
    @PostMapping("mall")
    public BaseRespVo updateMall(@RequestBody SystemMallVo systemMallVo){

        systemService.updateMall(systemMallVo);
        return BaseRespVo.ok();
    }

    /**
     * 查询运费配置
     * @return
     */
    @GetMapping("express")
    public BaseRespVo queryExpress(){

        SystemExpressVo systemExpressVo = systemService.selectExpress();

        return BaseRespVo.ok(systemExpressVo);
    }

    /**
     * 修改运费配置
     * @param systemExpressVo
     * @return
     */
    @PostMapping("express")
    public BaseRespVo updateExpress(@RequestBody SystemExpressVo systemExpressVo){

        systemService.updateExpress(systemExpressVo);

        return BaseRespVo.ok();
    }

    /**
     * 查询订单配置
     * @return
     */
    @GetMapping("order")
    public BaseRespVo queryOrder(){

        SystemOrderVo systemOrderVo = systemService.selectOrder();

        return BaseRespVo.ok(systemOrderVo);
    }

    /**
     * 修改订单配置
     * @param systemOrderVo
     * @return
     */
    @PostMapping("order")
    public BaseRespVo updateOrder(@RequestBody SystemOrderVo systemOrderVo){

        systemService.updateOrder(systemOrderVo);

        return BaseRespVo.ok();
    }

    /**
     * 查询小程序配置
     * @return
     */
    @GetMapping("wx")
    public BaseRespVo queryWx(){

        SystemWxVo systemWxVo = systemService.selectWx();

        return BaseRespVo.ok(systemWxVo);
    }

    /**
     * 修改小程序配置
     * @param systemWxVo
     * @return
     */
    @PostMapping("wx")
    public BaseRespVo updateWx(@RequestBody SystemWxVo systemWxVo){

        systemService.updateWx(systemWxVo);

        return BaseRespVo.ok();

    }

}
